import request from '@/utils/api'

export const collectNote = (userId, noteId) => {
  return request.post('/api/collections', null, { params: { userId, noteId } })
}

export const uncollectNote = (userId, noteId) => {
  return request.delete('/api/collections', { params: { userId, noteId } })
}

export const uncollectAllByUserId = (userId) => {
  return request.delete(`/api/collections/user/${userId}`)
}

export const uncollectAllByNoteId = (noteId) => {
  return request.delete(`/api/collections/note/${noteId}`)
}

export const isCollected = (userId, noteId) => {
  return request.get('/api/collections/status', { params: { userId, noteId } })
}

export const getCollectionCountByNoteId = (noteId) => {
  return request.get(`/api/collections/note/${noteId}/count`)
}

export const getCollectionCountByUserId = (userId) => {
  return request.get(`/api/collections/user/${userId}/count`)
}

export const getCollectionsByUserId = (userId) => {
  return request.get(`/api/collections/user/${userId}`)
}

export const getCollectionsByNoteId = (noteId) => {
  return request.get(`/api/collections/note/${noteId}`)
}